﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="OperationView.aspx.cs"
    Inherits="Demo.Web.Operation.OperationView" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Operación</title>
    <style type="text/css">
        .search-item
        {
            font: normal 11px tahoma, arial, helvetica, sans-serif;
            padding: 3px 10px 3px 10px;
            border: 1px solid #fff;
            border-bottom: 1px solid #eeeeee;
            white-space: normal;
            color: #555;
        }
        
        .search-item h3
        {
            display: block;
            font: inherit;
            font-weight: bold;
            color: #222;
        }
        
        .search-item h3 span
        {
            float: right;
            font-weight: normal;
            margin: 0 0 5px 5px;
            width: 100px;
            display: block;
            clear: none;
        }
        
        p
        {
            width: 650px;
        }
        
        .ext-ie .x-form-text
        {
            position: static !important;
        }
    </style>
    <link href="../../../../resources/css/examples.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
        var onKeyUp = function (field) {
            var v = this.getRawValue(),
                field;

            if (this.startDateField) {
                field = Ext.getCmp(this.startDateField);
                field.setMaxValue();
                this.dateRangeMax = null;
            } else if (this.endDateField) {
                field = Ext.getCmp(this.endDateField);
                field.setMinValue();
                this.dateRangeMin = null;
            }

            field.validate();
        };

        var commandHandler = function(command, record) {
            switch (command) {
            case "Edit":
                var win = App.AddResource;
                win.clearContent();
                win.show();
                win.setTitle('Modificar Recurso');
                win.load({
                    url: "AddResourceView.aspx",
                    params: {
                        Id: record.get('Id').toString(),
                        DateStart: Ext.getCmp('txtDateStar').getValue(),
                        DateEnd: Ext.getCmp('txtDateEnd').getValue()
                    }
                });

                break;
            }
        };

        var OpenWindow = function() {
            debugger;
            var win = App.AddResource;
            win.clearContent();
            win.show();
            win.setTitle('Agregar Recurso');
            win.load({
                url: "AddResourceView.aspx",
                params: {
                    DateStart: Ext.getCmp('txtDateStar').getValue(),
                    DateEnd: Ext.getCmp('txtDateEnd').getValue()
                }
            });
        };
       

    </script>
</head>
<body>
    <form id="Form1" runat="server">
    <div>
        <ext:ResourceManager ID="ResourceManager1" ViewStateMode="Enabled" runat="server" />
        <ext:FormPanel ID="FormPanel1" runat="server" Header="false" AnchorHorizontal="100%"
            Title="Operación" BodyPadding="10" Padding="10" Layout="AnchorLayout">
            <Items>
                <%-- seccion proyecto inico--%>
                <ext:Panel runat="server" Title="Información de Proyecto" AnchorHorizontal="100%"
                    Layout="AnchorLayout" BodyPadding="10">
                    <Items>
                        <ext:FieldContainer ID="FieldContainer2" runat="server" FieldLabel="Proyecto" AnchorHorizontal="100%"
                            Layout="AnchorLayout">
                            <Items>
                                <ext:ComboBox ID="cboProyect" runat="server" DisplayField="Name" ValueField="Id"
                                    TypeAhead="false" AnchorHorizontal="46%" PageSize="10" HideBaseTrigger="true"
                                    MinChars="1">
                                    <ListConfig LoadingText="Searching..." ID="ctl120">
                                        <ItemTpl ID="ItemTpl1" runat="server">
                                            <Html>
                                                <div class="search-item">
							                 <h3><span>{Id}</span>{Name}</h3>						     
						                    </div>
                                            </Html>
                                        </ItemTpl>
                                    </ListConfig>
                                    <Store>
                                        <ext:Store ID="Store1" runat="server" AutoLoad="false">
                                            <Proxy>
                                                <ext:AjaxProxy Url="../Common/Proyect.ashx">
                                                    <ActionMethods Read="POST" />
                                                    <Reader>
                                                        <ext:JsonReader Root="proyects" TotalProperty="total" />
                                                    </Reader>
                                                </ext:AjaxProxy>
                                            </Proxy>
                                            <Model>
                                                <ext:Model ID="Model1" runat="server">
                                                    <Fields>
                                                        <ext:ModelField Name="Id" />
                                                        <ext:ModelField Name="Name" />
                                                    </Fields>
                                                </ext:Model>
                                            </Model>
                                        </ext:Store>
                                    </Store>
                                    <DirectEvents>
                                        <Select OnEvent="CboProyect_SelectChange">
                                        </Select>
                                    </DirectEvents>
                                </ext:ComboBox>
                            </Items>
                        </ext:FieldContainer>
                        <ext:FieldContainer runat="server" AnchorHorizontal="100%" Layout="AnchorLayout">
                            <Items>
                                <ext:TextField ID="txtHour" runat="server" FieldLabel="Horas" Width="200" />
                                <ext:TextArea ID="txtTecnology" AnchorHorizontal="50.3%" Rows="3" AutoScroll="true"
                                    runat="server" FieldLabel="Tecnologia" />
                            </Items>
                        </ext:FieldContainer>
                        <ext:FieldContainer runat="server" Layout="HBoxLayout" Border="false" AnchorHorizontal="10">
                            <Items>
                                <ext:TextField ID="txtDateStar" runat="server" FieldLabel="Fecha Inicio" Width="250" />
                                <ext:TextField ID="txtDateEnd" runat="server" FieldLabel="Fecha Fin" Width="250" />
                            </Items>
                        </ext:FieldContainer>
                    </Items>
                </ext:Panel>
                <%-- seccion proyecto fin--%>
                <ext:Container runat="server" Height="10">
                    <Items>
                    </Items>
                </ext:Container>
                <ext:GridPanel ID="grdResources" runat="server" Title="Recursos" AnchorHorizontal="100%"
                    Layout="AnchorLayout" SortableColumns="false" Draggable="false" EnableColumnHide="false"
                    EnableColumnMove="false" AutoScroll="true" Frame="true">
                    <Store>
                        <ext:Store ID="stReosurce" runat="server" GroupField="Name" OnReadData="grdResources_ReadData"
                            RemoteSort="true" PageSize="3" AutoLoad="true" RemotePaging="true">
                            <Model>
                                <ext:Model ID="mdResource" runat="server">
                                    <Fields>
                                        <ext:ModelField Name="Id" />
                                        <ext:ModelField Name="Name" />
                                        <ext:ModelField Name="TypeLevel" />
                                        <ext:ModelField Name="Cost" Type="Float" />
                                        <ext:ModelField Name="DateStart" />
                                        <ext:ModelField Name="DateEnd" />
                                        <ext:ModelField Name="HourAssigned" />
                                    </Fields>
                                </ext:Model>
                            </Model>
                            <AutoLoadParams>
                                <ext:StoreParameter Name="limit" Value="3" Mode="Value" />
                                <ext:StoreParameter Name="start" Value="0" Mode="Value" />
                            </AutoLoadParams>
                            <Proxy>
                                <ext:PageProxy />
                            </Proxy>
                        </ext:Store>
                    </Store>
                    <ColumnModel ID="ColumnModel1" runat="server">
                        <Columns>
                            <ext:Column ID="Name" runat="server" Header="Nombre" DataIndex="Name" Flex="1">
                            </ext:Column>
                            <ext:Column ID="Column1" runat="server" Header="Fecha Inicio" DataIndex="DateStart">
                            </ext:Column>
                            <ext:Column ID="Column2" runat="server" Header="Fecha Fin" DataIndex="DateEnd">
                            </ext:Column>
                            <ext:SummaryColumn ID="SummaryColumn1" runat="server" Width="75" Text="Cost" DataIndex="Cost"
                                SummaryType="Sum">
                                <Renderer Format="UsMoney" />
                                <SummaryRenderer Fn="Ext.util.Format.usMoney" />
                                <Editor>
                                    <ext:NumberField ID="NumberField2" runat="server" AllowBlank="false" AllowNegative="false"
                                        StyleSpec="text-align:left" />
                                </Editor>
                            </ext:SummaryColumn>
                            <ext:SummaryColumn ID="SummaryHours" runat="server" Width="75" Text="HourAssigned"
                                DataIndex="HourAssigned" SummaryType="Sum">
                                <Renderer Handler="return value +' horas';" />
                                <SummaryRenderer Handler="return value +' horas';" />
                                <Editor>
                                    <ext:NumberField ID="NumberField1" runat="server" AllowBlank="false" AllowNegative="false"
                                        StyleSpec="text-align:left" />
                                </Editor>
                            </ext:SummaryColumn>
                            <ext:ImageCommandColumn ID="ImageCommandColumn1" runat="server" Width="20">
                                <Commands>
                                    <ext:ImageCommand CommandName="Delete" Icon="Delete">
                                        <ToolTip Text="Eliminar" />
                                    </ext:ImageCommand>
                                </Commands>
                                <DirectEvents>
                                    <Command OnEvent="BtnDeleteConfirm_Click">
                                        <ExtraParams>
                                            <ext:Parameter Name="id" Value="record.data['Id']" Mode="Raw">
                                            </ext:Parameter>
                                        </ExtraParams>
                                    </Command>
                                </DirectEvents>
                            </ext:ImageCommandColumn>
                            <ext:CommandColumn ID="clmEdit" runat="server" Width="20">
                                <Commands>
                                    <ext:GridCommand CommandName="Edit" Icon="ApplicationFormEdit">
                                        <ToolTip Text="Editar" />
                                    </ext:GridCommand>
                                </Commands>
                                <Listeners>
                                    <Command Handler="commandHandler(command,record);" />
                                </Listeners>
                            </ext:CommandColumn>
                        </Columns>
                    </ColumnModel>
                    <Features>
                        <ext:GroupingSummary ID="GroupingSummary1" runat="server" GroupHeaderTplString="{name}"
                            HideGroupedHeader="true" EnableGroupingMenu="false">
                        </ext:GroupingSummary>
                    </Features>
                    <TopBar>
                        <ext:Toolbar ID="tbResource" runat="server">
                            <LayoutConfig>
                                <ext:HBoxLayoutConfig Align="top" Pack="End" />
                            </LayoutConfig>
                            <Items>
                                <ext:Button ID="btnNew" CommandName="Add" runat="server" Text="Nuevo" Icon="Add">
                                    <Listeners>
                                        <Click Fn="OpenWindow" />
                                    </Listeners>
                                </ext:Button>
                            </Items>
                        </ext:Toolbar>
                    </TopBar>
                    <SelectionModel>
                        <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" Mode="Multi" />
                    </SelectionModel>
                    <BottomBar>
                        <ext:PagingToolbar ID="PagingToolbar1" runat="server">
                            <Items>
                                <ext:Label ID="Label1" runat="server" Text="Page size:" />
                                <ext:ToolbarSpacer ID="ToolbarSpacer1" runat="server" Width="10" />
                                <ext:ComboBox ID="ComboBox1" runat="server" Width="80">
                                    <Items>
                                        <ext:ListItem Text="5" />
                                        <ext:ListItem Text="10" />
                                        <ext:ListItem Text="20" />
                                        <ext:ListItem Text="25" />
                                        <ext:ListItem Text="50" />
                                    </Items>
                                    <SelectedItems>
                                        <ext:ListItem Value="5" />
                                    </SelectedItems>
                                    <Listeners>
                                        <Select Handler="#{grdOperation}.store.pageSize = parseInt(this.getValue(), 10); #{grdOperation}.store.load();" />
                                    </Listeners>
                                </ext:ComboBox>
                            </Items>
                        </ext:PagingToolbar>
                    </BottomBar>
                </ext:GridPanel>
            </Items>
        </ext:FormPanel>
        <ext:Button ID="btnRefresh" runat="server" Text="Refresh" Hidden="true" Disabled="true">
            <DirectEvents>
                <Click OnEvent="BtnRefresh_Click">
                    <EventMask ShowMask="true" />
                </Click>
            </DirectEvents>
        </ext:Button>
        <ext:Window ID="AddResource" runat="server" Icon="ApplicationFormEdit" Width="600"
            Height="300" Hidden="true" Modal="true" Resizable="false" Draggable="false" BodyPadding="0">
            <Defaults>
                <ext:Parameter Name="margins" Value="0 0 0 0" Mode="Value" />
            </Defaults>
            <Loader ID="Loader1" runat="server" AutoLoad="false" Mode="Frame">
            </Loader>
        </ext:Window>
    </div>
    </form>
</body>
</html>
